import java.awt.Dimension;
import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import FilePanel.FilePanel;
import PlugIn.PlugIn;

public class Window extends JFrame {

	private static final long serialVersionUID = 1L;
	private static final int WIDTH = 600;
	private static final int HEIGHT = 400;
	
	//Variables
	FilePanel panel;
	JPanel pluginContainer;
	ArrayList<PlugIn> plugins;
	
	
	/**
	 * Creates the main window application
	 * @param title the title of the application
	 * @param panel the panel where everything will be in
	 */
	public Window(String title,FilePanel panel) {
		
		super(title);
		this.panel = panel;
		initWindow();
		initComponents();
		this.pack();
		this.setVisible(true);
	}
	
	/**
	 * initiate the components of the window
	 */
	private void initComponents() {
		Box pane = new Box(BoxLayout.X_AXIS);
		pane.add( panel.getView() );
		pluginContainer=new JPanel(new GridLayout(0, 1));
		pluginContainer.setBorder(BorderFactory.createTitledBorder("Plugins"));
		pane.add(pluginContainer);
		this.setContentPane(pane);		
	}

	/**
	 * sets the size of the window
	 */
	private void initWindow() {
		this.setPreferredSize(new Dimension(WIDTH,HEIGHT));
	}
	
	/**
	 * adds the plugin to the window container
	 * @param p the plugin to add
	 */
	public void addPlugin(PlugIn p){
		pluginContainer.add(p.getView());
		this.repaint();
		this.validate();
	}
	
	
}
